const http = require('http');

const express = require('express'),
  bodyParser = require('body-parser');

const app = express();

app.use(bodyParser.urlencoded({
  'extended': true
}));
app.use(bodyParser.json());
app.use(bodyParser.text({
  'defaultCharset': 'utf-8'
}));


const server = http.createServer(app);

const githook = require('./script/githook');
const tlf_cp_ui=require('./script/tlf-cp-ui');
app.post('/git', function(req, res, next) {
  console.log('body:', req.body);
  tlf_cp_ui().then(result => {
    console.log(result);
    res.json({});
  }).catch(e => console.error(e));
});

server.listen(8181);
console.log('git hook service started on 8181');

process.on('error', function(e) {
  console.log(e);
});
